package com.health.system.dao.system;

import java.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import com.health.system.javacommon.base.BaseIbatis3Dao;
import com.health.system.model.system.*;
import com.health.system.dao.system.*;
import com.health.system.service.system.impl.*;
import com.health.system.service.system.*;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;


@Component
public class RoleDao extends BaseIbatis3Dao<Role,java.lang.String>{

	public Class getEntityClass() {
		return Role.class;
	}
	
	public void saveOrUpdate(Role entity) {
		if(entity.getId() == null) 
			save(entity);
		else 
			update(entity);
	}
	
	public int removeByIdArry(Role u) {
		int i=-1;
		i =delete("Role.removeByIdArry", u);
		return i;
	}

	public Page findByPageRequest(PageRequest pageRequest) {
		return pageQuery("Role.pageSelect",pageRequest);
	}
	
	public List getRoleList(Role role){
		return getList("Role.getSubsetTree",role);
	}
	/**
	 * @param type
	 *            类型
	 * @return 根据类型取出所有权限名及权限对应资源
	 */
	public List selectList() { 
		List list = getSqlSessionTemplate().selectList("Role.getAll",null);
		return list;
	}
	/**
	 * 多条件查询数据
	 * @author bzq
	 * @param Map
	 */
	public List getListByMap(Map map){
		return getList("Role.getListByMap",map);
	}
	/**
	* <p>查询所有节点树</p>
	* <p>以树形结构查询所有节点</p>
	* @param Role u
	* @author bzq
	* @return List<Role>
	*/
	public List getAllTree(){
		return getList("Role.getAllTree",null);
	}
	
	/**
	 * <p>查询当前节点的所有上级节点</p>
	 * <p>以树形结构查询</p>
	 * @param Role u
	 * @author bzq
	 * @return List<Role>
	*/
	@Transactional(readOnly=true)
	public List getParentTree(Role role){
		return getList("Role.getParentTree",role);
	}
	/**
	 * <p>查询当前节点的所有下级节点</p>
	 * <p>以树形结构查询</p>
	 * @param Role u
	 * @author bzq
	 * @return List<Role>
	*/
	@Transactional(readOnly=true)
	public List getSubsetTree(Role role){
		return getList("Role.getSubsetTree",role);
	}
	
}
